package com.toddding.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.toddding.domain.User;
import com.toddding.mapper.UserMapper;
import com.toddding.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 用户登录
     *
     * @param loginName
     * @param loginPwd
     * @return
     */
    @Override
    public User queryUser(String loginName, String loginPwd) {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getLoginName, loginName).eq(User::getLoginPwd, loginPwd);
        User user = this.userMapper.selectOne(queryWrapper);
        return user;
    }

    /**
     * 修改用户信息
     *
     * @param updateUser
     * @return
     */
    @Override
    public int updatePwd(User updateUser) {
        int count = this.userMapper.updateById(updateUser);
        return count;
    }
}
